package org.cuasloi.rabbitmq.basic;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class BasicProduceController {

    // 注入SpringAMQP提供的模板
    @Autowired
    private RabbitTemplate rabbitTemplate;

    @GetMapping("basicQueue/{msg}")
    public void sendMsgToBasicQueue(@PathVariable("msg") String msg) {
        // 发送消息到队列
        rabbitTemplate.convertAndSend("basic.queue", msg);
    }
}
